<%@tag pageEncoding="UTF-8" isELIgnored="false"  %>

    <input type="text" id="code" placeholder="请扫描条码" class="layui-input" style="display: none;width: 180px;">
    <button  id="barcode"  class="layui-btn layui-btn-normal">条码</button>


<script>
    $("#barcode").click(function () {
        if (isTrue($("#code").attr("flag"))) {
            $("#code").css("display","none");
            $("#code").attr("flag", false);
        }else {
            $("#code").css("display","inline");
            $("#code").attr("flag", true);
        }
    });

    $("#code").keypress(function (e) {
        if (e.which == 13) {
            let temp = $("#code").val();
            get("${baseUrl}goods/goods/getVoByCode.action?code="+temp, function (res) {
                $("#code").val("");
                if (res.code != 1) {
                    errTip(res.msg);
                } else {
                    //成功，则处理数据
                    let data = res.data;
                    data.goodsId = data.id;
                    data.number = 1;
                    let unitVo = genUnitVoByCode(data.goodsUnitVoList, temp);
                    data.price = unitVo.wholesalePrice;
                    data.amount = data.price;
                    data.unitId = unitVo.unitId;
                    data.times = unitVo.times;

                    processGoods(res.data);
                }
            });
        }
    });
</script>